package com.dnndo.common.utils.oss;


import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class OssConfiguration {
    private static final Logger log = LoggerFactory.getLogger(OssConfiguration.class);

    @Bean
    @ConditionalOnMissingBean
    public AliOssUtil getAliOssUtil(AliOssProperties aliOssProperties) {
        log.info("创建OssUtil");
        return new AliOssUtil(
                aliOssProperties.getEndpoint(),
                aliOssProperties.getAccessKeyId(),
                aliOssProperties.getAccessKeySecret(),
                aliOssProperties.getBucketName(),
                aliOssProperties.getCdnUrl(),
                aliOssProperties.getUploadPath(),
                aliOssProperties.getProtocolPath(),
                aliOssProperties.getAvatarPath()
        );
    }
}
